package cn.hdustea.shopNavigation.ui.presenter

import cn.hdustea.shopNavigation.entity.Child
import cn.hdustea.shopNavigation.ui.contract.ChildContract
import cn.hdustea.shopNavigation.ui.model.ChildModel
import com.hdustea.base.base.BasePresenter

/**
 * <pre>
 *     author : HuQiang
 *     time   : 2020/09/21
 *     desc   :
 *     version: 1.0
 * </pre>
 */
class ChildPresenter(mView: ChildContract.View) : BasePresenter<ChildContract.View, ChildContract.Model>(mView), ChildContract.Presenter {

    override fun getModel(): ChildContract.Model = ChildModel()

    override fun getChildList(page: Int, isRefresh: Boolean) {
        mModel.getChildList(page, object : PresenterCallback<MutableList<Child>>() {

            override fun callback(data: MutableList<Child>) {
                mView?.dismissLoading()
                mView?.setChildList(data, isRefresh)
            }

        })
    }

    override fun getSearchList(keyword: String) {
        mModel.getSearchList(keyword, object : PresenterCallback<MutableList<Child>>() {

            override fun callback(data: MutableList<Child>) {
                mView?.dismissLoading()
                mView?.setSearchList(data)
            }

        })
    }


} 